﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HanGu.Services.Interface;
using HanGu.Common;
using HanGu.Entity;

namespace Hangu.WebClient.Controllers
{

    public class VipBaseController : BaseController
    {

        protected static readonly IMemberInfo serviceMemberInfo = ServiceFactory.GetService<IMemberInfo>();
        protected static readonly IChangeChargeRecorde serviceChangeCharge = ServiceFactory.GetService<IChangeChargeRecorde>();
        protected static readonly IChangeGradeRecorde serviceGrade = ServiceFactory.GetService<IChangeGradeRecorde>();
        protected static readonly IChargeRecorde serviceCharge = ServiceFactory.GetService<IChargeRecorde>();
        /// <summary>
        /// 不验证的页面
        /// </summary>
        static readonly List<string> IgoreActions = new List<string>() { "login", "register", "getValidateCode", "forgetpwd" };
 
        [ValidateInput(false)]
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            if (!IgoreActions.Contains(filterContext.ActionDescriptor.ActionName))
            {
                if (Session["Member"] != null)
                {
                    CurentUser = Session["Member"] as CurrentUserDTO;
                }
                else
                {
                    Response.Redirect("/Vip/login");
                }
            }

          
        }

        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);
            ViewData["Member"] = CurentUser;
        }
      
    }
}
